home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / basic / mildred / mildred.lha / lha / Starfield2.lha / starfield2.ascii < prev    next >
Text File  |  1999-03-21  |  4KB  |  150 lines

  1.  
  2. ;Horizontal Starfield with SineWave Logo
  3. ;
  4. ;Programmed by : Bruce Henderson (BaH)  07.03.1999
  5.  
  6. ; Includes segments of code by
  7. ; Mikkel Loekke, aka. FlameDuck,
  8. ; (explosion & sine demo)
  9. ; and Paul West (for Particle changes in Explosion demo)
  10.  
  11. ; Runs at 25fps on 060/50
  12.  
  13. ; Modified by Paul West on 20.03.1999 to use OffsetList with MScroll
  14.  
  15. WBStartup
  16. NoCli
  17.  
  18.  
  19. NEWTYPE .point
  20.   x.w
  21.   y.w
  22. End NEWTYPE
  23. NEWTYPE .point2
  24.   xspeed.w
  25.   yspeed.w
  26. End NEWTYPE
  27.  
  28. #numpnts=255                        ; Points set for each horizontal line.
  29. degrad.q = Pi/180                   ; Degree/Radian Converter
  30.  
  31. Dim pnt.point (#numpnts)
  32. Dim pnt2.point2 (#numpnts)
  33.  
  34. Dim Lookup.w(460)                   ; Setup our sine lookup table.
  35. For i=0 To 460                      ; Array needs to be .w. If you use .q it will not work properly
  36.   Lookup(i)=Sin((i)*degrad*2)*20
  37. Next
  38.  
  39. NEWTYPE.OffsetList
  40.   LineWidth.w
  41.   X1Offset.w
  42.   X2Offset.w
  43.   SourceModuloOffset.w
  44. End NEWTYPE
  45. Dim rows.OffsetList(460)
  46. rows(0)\LineWidth=100,0,Lookup(0),0
  47. For y=1 To 460                            ; Do the sine wavey bits.
  48.   rows(y)\LineWidth=100
  49.   rows(y)\X1Offset=0
  50.   rows(y)\X2Offset=Lookup(y)-Lookup(y-1)
  51.   rows(y)\SourceModuloOffset=0
  52. Next
  53.  
  54. DEFTYPE.l
  55.  
  56. MCPU Processor                      ; Tell Mildred which CPU it should use.
  57. Mc2pCPUmode Processor               ; Tell Mildred which CPU it should use for c2p.
  58.  
  59. MReserveBitmaps 2                   ; Tell Mildred that we're going to use 3 chunky bitmaps.
  60. MReservec2pWindows 1                ; Tell it we only need one c2p display.
  61.  
  62. InitBank 0,320*256,$10000
  63. CludgeBitMap 2,320,256,8,Bank(0)
  64. LoadBitMap 2,"Logo.IFF"
  65. MBitmap 1,320,256                   ; This will contain our chunky buffer.
  66.  
  67. MPlanar16ToBitmap 1,Bank(0),320,256,320,256
  68.  
  69.  
  70.  
  71. .initgraphics
  72. MBitmap 0,320,256                   ; This will contain our chunky buffer.
  73.  
  74. Mc2pWindow 0,320,256                ; Setup structures for c2p conversions.
  75.  
  76. Dim bm.l(1)                         ; We use two bitmaps for double buffering
  77.  
  78. For l=0 To 1
  79.   ; Get some free CHIP memory
  80.   bm(l)=AllocMem(320*256,$10002)
  81.   If bm(l)   ; and if we succeed
  82.     ; make it a planar bitmap.
  83.     CludgeBitMap l,320,256,8,bm(l)
  84.   Else
  85.     End
  86.   EndIf
  87. Next l
  88.  
  89. Dim scrtaglst.TagItem(7)            ; All this stuff sets up our
  90. scrtaglst(0)\ti_Tag = #SA_Left      ; Taglist for the screen we
  91. scrtaglst(0)\ti_Data = 0            ; want.
  92. scrtaglst(1)\ti_Tag = #SA_Depth
  93. scrtaglst(1)\ti_Data = 8
  94. scrtaglst(2)\ti_Tag = #SA_Width
  95. scrtaglst(2)\ti_Data = 320
  96. scrtaglst(3)\ti_Tag = #SA_Height
  97. scrtaglst(3)\ti_Data = 256
  98. scrtaglst(4)\ti_Tag = #SA_BitMap
  99. scrtaglst(4)\ti_Data = Addr BitMap (0)
  100. scrtaglst(5)\ti_Tag = #SA_ShowTitle
  101. scrtaglst(5)\ti_Data = 0
  102. scrtaglst(6)\ti_Tag = #SA_Draggable
  103. scrtaglst(6)\ti_Data = 0
  104. scrtaglst(7)\ti_Tag = #TAG_END      ; The most important tag of them all.
  105.  
  106. ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen.
  107.  
  108. DecodePalette 0,?incpal             ; Get our IncBin'ed palette info.
  109. ShowPalette 0                       ; Attach our palette to the screen.
  110.  
  111.  
  112. MParticleFormat 0
  113.  
  114. For t.l=0To #numpnts                ; Set up the starfield
  115.   pnt(t)\x=Rnd(319)+1
  116.   pnt(t)\y=t MOD 256
  117.   pnt2(t)\xspeed=(Rnd(5)+1)*-1      ; Some random Speeds. (Remove *-1 to reverse)
  118.   pnt2(t)\yspeed=0
  119. Next
  120.  
  121. pge=0
  122.  
  123. Repeat                              ; Repeat our mainloop ....
  124.   deg+4
  125.   If deg>358
  126.     deg=0
  127.   EndIf
  128.  
  129.   Mc2p bm(pge)                      ; Double Buffer
  130.   ShowBitMap pge
  131.   WaitTOF_                          ; Smooooooth...
  132.   pge=1-pge
  133.   MCls
  134.  
  135.   MAddToXParticles &pnt(0)\x,#numpnts,&pnt2(0)\xspeed    ; Move the Stars
  136.   MWrapXParticles &pnt(0)\x,#numpnts                     ; If a Star falls off the end, put it back on the other side;
  137.   MPlotParticles &pnt(0)\x,#numpnts,255                 ; Draw them.
  138.  
  139.   Temp.w=rows(deg)\X2Offset
  140.   rows(deg)\X2Offset=Lookup(deg)
  141.   MScroll 0,0,100,100,100,70,1,&rows(deg)
  142.   rows(deg)\X2Offset=Temp
  143.  
  144. Until RawStatus($45)  ; .... Until we press Escape
  145. End                                 ; End of program.
  146.  
  147. Even                                ; put following data on an even address. Minor speed increase.
  148. .incpal
  149. IncBin "Logo.PAL" ; Include our palette information in the binary.
  150.